﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace RomanNumeralKata.Core.Constants
{
    /// <summary>
    ///     maybe a bi-directional dictionary later
    /// </summary>
    public class NumberRepresentations
    {
        /// <summary>
        ///     guess we could come up with something to signify that a numeral
        ///     is subtractable, but that would lend to the grammar changing sometime,
        ///     so I see no reason to go outside of this realm given the 3000 constraint
        /// </summary>
        private static readonly Dictionary<string, int> _romanToArabicLookup =
            new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
            {
                {"I", 1},
                {"IV", 4},
                {"V", 5},
                {"IX", 9},
                {"X", 10},
                {"XL", 40},
                {"L", 50},
                {"XC", 90},
                {"C", 100},
                {"CD", 400},
                {"D", 500},
                {"CM", 900},
                {"M", 1000}
            };

        /// <summary>
        ///     Reverse lookup to go from arabic to roman numeral.
        ///     Uses previous table and creates opposite direction once
        /// </summary>
        private static readonly Dictionary<int, string> _arabicToRomanLookup =
            RomanToArabicLookup.ToDictionary(kv => kv.Value, kv => kv.Key);

        public static Dictionary<string, int> RomanToArabicLookup
        {
            get { return _romanToArabicLookup; }
        }

        public static Dictionary<int, string> ArabicToRomanLookup
        {
            get { return _arabicToRomanLookup; }
        }
    }
}